﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;
using OnlineEducation.Data;
using OnlineEducation.Extensions;
using OnlineEducation.ExternalService;
using OnlineEducation.Models;

namespace OnlineEducation.Controllers
{
    [Authorize]
    public class HomeController : BaseController
    {

        private readonly ILogger _logger;

        private readonly ApplicationDbContext _context;
        private readonly IDistributedCache _distributedCache;
        public HomeController(ILogger<HomeController> logger,
                IDistributedCache distributedCache,
                ApplicationDbContext context)
        {

            _logger = logger;
            _distributedCache = distributedCache;
            _context = context;

        }

        public IActionResult Index()
        {
            if (User.IsInRole("SuperAdmin"))
            {
                return View("AdminIndex");
            }
            else if (User.IsInRole("Teacher"))
            {
                return View("TeacherIndex");
            }
            else
            {
                return View("Index");
            }


        }
        public IActionResult About()
        {

            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }


 




    }
}
